<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex align-center benben-position-layout flex search_flex_0"
				:style="{height:(100+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex align-center flex-sub search_fd0_0'>
					<text class='fu-iconfont2  search_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">&#xE794;</text>
					<view class='flex align-center search_fd0_0_c1'>
						<image class='search_fd0_0_c1_c0' mode="aspectFit" :src='STATIC_URL+"195.png"'></image>
						<input class='flex-sub search_fd0_0_c1_c1' type="text" :focus='true' :placeholder="`搜索`"
							confirm-type="search" :maxlength="50" placeholder-style="color:#BFBFBF;font-size:28rpx"
							@confirm="addSearchHistoryFunc()" v-model="keyword" />
						<image class='search_fd0_0_c1_c2' mode="aspectFit" :src='STATIC_URL+"196.png"'
							@tap="ClearInputFunc()" v-if=" keyword!=''"></image>
					</view>
				</view>

			</view>
			<view :style="{height: (100+StatusBarRpx)+'rpx'}"></view>

			<view class="course">
				<scroll-view class="course_left" scroll-y="true" :style="{height: (scrollHeight - (100+StatusBarRpx)) +'rpx'}">
					<view class="class_left_item" v-for="(item, index) in classification" :key="index" @tap.stop="selectCate(item.aid)">
						<view class="class_left_item_icon" v-if="cate_id == item.aid"></view>
						<view class="class_left_item_name" :class="cate_id == item.aid ? 'active_name' : ''">{{item.name}}</view>
					</view>

				</scroll-view>
				<scroll-view class="course_right" scroll-y="true" :style="{height: (scrollHeight - (100+StatusBarRpx)) +'rpx'}" @scrolltolower="onBottom">
					<view class="loading_css" v-if="isShow">
						<u-loading size="36" color="#F35D2A"></u-loading>
						<view>加载中</view>
					</view>
					<template v-else>
						<view class="course_item" v-for="(item, index) in list" :key="index" @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="`/pages/shouye/oneAppointment/courseDetails?aid=${item.aid}&data_type=2`">
							<view class="course_item_left">
								<image :src='item.thumb' mode="aspectFill"></image>
							</view>
							<view class="course_item_right">
								<view class="course_item_right_1">{{item.name}}</view>
								<view class="course_item_right_2">
									<view class="course_item_right_2_1">
										{{item.course_type_txt}}
									</view>
								</view>
							</view>
						</view>
						<view class="loadmore" v-if="last_page > 1">
							<u-loadmore font-size="24" :status="status" :icon-type="iconType" :load-text="loadText" />
						</view>
						<view class="noData" v-if="list.length == 0 && !isShow">
							<image :src='STATIC_URL+"no.png"'></image>
						</view>
					</template>
				</scroll-view>
			</view>

		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				scrollHeight: 0,  // 屏幕高度
				keyword: "",
				cate_id: "",
				classification: [],
				
				"list": [],
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"iconType": 'flower',
				"loadText": {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				"isShow": true,
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
		},
		watch: {},
		onLoad(options) {
			let {
				cate_id
			} = options
			if (cate_id !== undefined) this.cate_id = cate_id;
			this.init();
			this.getCourseClassification();
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPageScroll(e) {

		},
		methods: {
			// 课程分类  post6556232bd672a
			getCourseClassification() {
				this.$api.post(global.apiUrls.post6556232bd672a, {
					from: 'more'
				}).then(res =>{
					// console.log(res);
					if (res.data.code == 1) {
						this.classification = res.data.data;
						if (this.classification.length > 0) {
							if (!this.cate_id) {
								this.cate_id = this.classification[0].aid;
							}
							this.getList();
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			getList() {
				this.$api.post(global.API_VERSION + '65b7491001784', {
					page: this.page,
					cate_id: this.cate_id,
					keyword: this.keyword
				}).then(res => {
					// console.log(res);
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.list = res.data.data.data;
						} else {
							this.list = this.list.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			onBottom() {
				if (this.page >= this.last_page) return;
				this.status = 'loading';
				this.page++;
				setTimeout(() => {
						
					if (this.page >= this.last_page) this.status = 'nomore';
					else this.status = 'loading';
					this.is_pull = false;
					this.getList();
				}, 500)
			},
			selectCate(cate_id) {
				this.cate_id = cate_id;
				this.page = 1;
				this.is_pull = true;
				this.isShow = true;
				this.getList();
			},
			addSearchHistoryFunc() {
				this.page = 1;
				this.is_pull = true;
				this.isShow = true;
				this.getList();
			},
			ClearInputFunc() {
				this.keyword = "";
				this.page = 1;
				this.is_pull = true;
				this.isShow = true;
				this.getList();
			},
			init() {
				let _this = this;
				uni.getSystemInfo({
					success: function(res) {
						// console.log(res.screenHeight); //屏幕高度  注意这里获得的高度宽度都是px 需要转换rpx
						// console.log(res.windowWidth); //可使用窗口宽度
						// console.log(res.windowHeight); //可使用窗口高度
						// console.log(res.screenWidth); //屏幕宽度
						var rpx = (res.screenHeight * (750 / res.windowWidth)) //将px 转换rpx
						_this.scrollHeight = rpx;
					}
				})
			},
			
		}
	};
</script>
<style lang="scss" scoped>
	.loading_css {
		// padding-top: 72rpx;
		text-align: center;
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -50%);
		view {
			color: #999999;
			font-size: 22rpx;
			margin-top: 16rpx;
		}
	}
	.noData {
		width: 100%;
		text-align: center;
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -50%);
		image {
			width: 380rpx;
			height: 350rpx;
		}
		view {
			font-size: 28rpx;
			color: #999999;
			margin-top: 28rpx;
		}
	}
	.course {
		display: flex;

		.course_left {
			width: 168rpx;
			margin-right: 20rpx;
			background: #fff;
			.class_left_item {
				padding: 32rpx 0;
				color: #666666;
				font-size: 28rpx;
				position: relative;
				.class_left_item_icon {
					width: 8rpx;
					height: 34rpx;
					border-radius: 4rpx;
					background: #F35D2A;
					position: absolute;
					top: 50%;
					left: 0;
					transform: translateY(-50%);
				}
				.class_left_item_name {
					padding: 0 24rpx;
					text-align: center;
				}
				.active_name {
					color: #F35D2A;
					font-weight: 500;
				}
			}
		}

		.course_right {
			width: calc(100% - 188rpx);
			position: relative;
			.course_item {
				background: #fff;
				border-radius: 16rpx;
				padding: 24rpx;
				margin-top: 20rpx;
				display: flex;
			
				.course_item_left {
					width: 160rpx;
					height: 160rpx;
			
					image {
						width: 100%;
						height: 100%;
						border-radius: 24rpx;
					}
				}
			
				.course_item_right {
					width: calc(100% - 180rpx);
					margin-left: 20rpx;
			
					.course_item_right_1 {
						font-size: 30rpx;
						text-overflow: ellipsis;
						overflow: hidden;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 2; /* 这里是超出几行省略 */
					}
					.course_item_right_2 {
						margin-top: 16rpx;
						display: flex;
						.course_item_right_2_1 {
							color: #FD9E30;
							font-size: 20rpx;
							background: rgba(255,255,255,0.2);
							padding: 2rpx 16rpx;
							opacity: 1;
							border: 1px solid #FD9E30;
							border-radius: 35rpx;
							margin-right: 16rpx;
						}
					}
				}
			}
		}
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
	}

	.search_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 100rpx;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.search_fd0_0_c1_c2 {
		width: 28rpx;
		height: 28rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.search_fd0_0_c1_c1 {
		margin: 0rpx 0rpx 0rpx 16rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333;
	}

	.search_fd0_0_c1_c0 {
		width: 24rpx;
		height: 24rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.search_fd0_0_c1 {
		background: rgba(246, 247, 249, 1);
		background-size: 100% auto !important;
		border-radius: 34rpx 34rpx 34rpx 34rpx;
		margin: 0rpx 0rpx 0rpx 24rpx;
		padding: 0rpx 24rpx 0rpx 24rpx;
		height: 64rpx;
		width: 444rpx;
	}

	.search_fd0_0_c0 {
		font-size: 36rpx;
		color: #333;
		font-weight: 500;
	}

	.search_fd0_0 {
		margin: 17rpx 32rpx 24rpx 32rpx;
	}

	.search_flex_1 {
		padding: 0rpx 0rpx 0rpx 0rpx;
	}

	.search_fd1_2 {
		font-size: 24rpx;
		font-weight: 400;
		color: #666666;
		margin: 0rpx 0rpx 32rpx 24rpx;
	}

	.search_fd1_1_c0_c1 {
		width: 18rpx;
		height: 18rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.search_fd1_1_c0_c0 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(51, 51, 51, 1);
		margin: 0rpx 16rpx 0rpx 0rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		max-width: 200rpx;
	}

	.search_fd1_1_c0 {
		background: var(--benbenbgColor5);
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		background-size: 100% auto !important;
		padding: 0rpx 40rpx 0rpx 40rpx;
		line-height: 56rpx;
		margin: 0rpx 12rpx 24rpx 12rpx;
	}

	.search_fd1_1 {
		padding: 0rpx 0rpx 0rpx 12rpx;
	}

	.search_fd1_0_c2 {
		width: 24rpx;
		height: 28rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 0rpx auto;
	}

	.search_fd1_0_c1 {
		font-size: 32rpx;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
	}

	.search_fd1_0_c0 {
		width: 34rpx;
		height: 34rpx;
		border-radius: 17rpx 17rpx 17rpx 17rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.search_fd1_0 {
		padding: 32rpx 0rpx 24rpx 0rpx;
		margin: 0rpx 24rpx 0rpx 24rpx;
	}

	.search_flex_2 {
		background: var(--benbenbgColor1);
		margin: 0rpx 105rpx 0rpx 105rpx;
		background-size: #eee;
		border-radius: 25rpx 25rpx 25rpx 25rpx;
		padding: 40rpx 0rpx 0rpx 0rpx;
	}

	.search_fd2_2_c1 {
		background: var(--benbenbgColor1);
		line-height: 110rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor5);
		width: 269rpx;
		height: 110rpx;
	}

	.search_fd2_2_c0 {
		border-right: 1px solid #EEEEEE;
		background: var(--benbenbgColor1);
		line-height: 110rpx;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor2);
		height: 110rpx;
		width: 270rpx;
	}

	.search_fd2_2 {
		border-top: 1px solid #eee;
	}

	.search_fd2_1 {
		font-size: 32rpx;
		font-weight: 400;
		line-height: 52rpx;
		color: #333333;
		margin: 40rpx 0rpx 39rpx 0rpx;
	}

	.search_fd2_0 {
		color: #333333;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 45rpx;
	}

	.search_fd3_1_c1_c0 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(51, 51, 51, 1);
	}

	.search_fd3_1_c1 {
		background: rgba(248, 248, 248, 1);
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		background-size: 100% auto !important;
		padding: 0rpx 40rpx 0rpx 40rpx;
		line-height: 56rpx;
		margin: 0rpx 12rpx 24rpx 12rpx;
	}

	.search_fd3_1_c0_c1 {
		width: 18rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		position: absolute;
		top: -8rpx;
		right: 4rpx;
	}

	.search_fd3_1_c0_c0 {
		font-size: 24rpx;
		font-weight: 400;
		color: var(--benbenFontColor9);
	}

	.search_fd3_1_c0 {
		border: 1px solid rgba(255, 127, 0, 1);
		background: var(--benbenbgColor1);
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		background-size: 100% auto !important;
		padding: 0rpx 40rpx 0rpx 40rpx;
		line-height: 56rpx;
		margin: 0rpx 12rpx 24rpx 12rpx;
		position: relative;
	}

	.search_fd3_1 {
		padding: 0rpx 0rpx 0rpx 12rpx;
	}

	.search_fd3_0_c2 {
		border: 1px solid rgba(191, 191, 191, 1);
		margin: 0rpx 0rpx 0rpx auto;
		padding: 8rpx 16rpx 8rpx 16rpx;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		color: #333333;
		font-size: 24rpx;
		font-weight: 400;
		line-height: 33rpx;
	}

	.search_fd3_0_c1 {
		font-size: 32rpx;
		font-weight: 700;
		color: rgba(51, 51, 51, 1);
	}

	.search_fd3_0_c0 {
		width: 34rpx;
		height: 34rpx;
		border-radius: 17rpx 17rpx 17rpx 17rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.search_fd3_0 {
		padding: 32rpx 0rpx 15rpx 0rpx;
		margin: 0rpx 24rpx 0rpx 24rpx;
	}

	.search_flex_4 {
		padding: 0rpx 24rpx 24rpx 24rpx;
	}

	.search_fd4_1_c1_c0_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: var(--benbenFontColor0);
	}

	.search_fd4_1_c1_c0_c0 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 8rpx 0rpx 0rpx;
	}

	.search_fd4_1_c1_c0 {
		background: var(--benbenbgColor5);
		margin: 16rpx 0rpx 0rpx 0rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		height: 80rpx;
	}

	.search_fd4_1_c0_c4_c1 {
		color: #FE5014;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 40rpx;
	}

	.search_fd4_1_c0_c4_c0 {
		width: 12rpx;
		height: 22rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 8rpx 0rpx 0rpx;
	}

	.search_fd4_1_c0_c3 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.search_fd4_1_c0_c2 {
		margin: 0rpx 16rpx 0rpx 0rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(34, 34, 34, 1);
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.search_fd4_1_c0_c1 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(51, 51, 51, 1);
		margin: 0rpx 34rpx 0rpx 11rpx;
	}

	.search_fd4_1_c0_c0 {
		width: 38rpx;
		height: 38rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.search_fd4_1_c0 {
		margin: 0rpx 0rpx 40rpx 0rpx;
	}

	.search_fd4_1 {
		background: var(--benbenbgColor1);
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		box-shadow: 0rpx 0rpx 16rpx rgba(0, 0, 0, 0.0800);
		background-size: 100% auto !important;
		padding: 32rpx 24rpx 56rpx 24rpx;
	}

	.search_fd4_0_c1 {
		font-size: 32rpx;
		font-weight: 700;
		color: rgba(51, 51, 51, 1);
	}

	.search_fd4_0_c0 {
		width: 34rpx;
		height: 34rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.search_fd4_0 {
		padding: 32rpx 0rpx 24rpx 0rpx;
	}

	.search_flex_5 {
		padding: 24rpx 24rpx 0rpx 24rpx;
	}

	.search_fd5_0_c1 {
		width: 20rpx;
		height: 20rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.search_fd5_0_c0 {
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		color: #333333;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 40rpx;
	}

	.search_fd5_0 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.search_fd6_0_c1_c0_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: #333;
	}

	.search_fd6_0_c1_c0_c0 {
		width: 80rpx;
		height: 80rpx;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		margin: 0rpx 0rpx 16rpx 0rpx;
	}

	.search_fd6_0_c1 {
		padding: 0rpx 0rpx 58rpx 0rpx;
	}

	.search_fd6_0_c0_c2_c0 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
	}

	.search_fd6_0_c0_c2 {
		margin: 0rpx 2rpx 0rpx 0rpx;
	}

	.search_fd6_0_c0_c1_c1 {
		font-size: 32rpx;
		font-weight: 700;
		color: #333;
		margin: 0rpx 16rpx 0rpx 16rpx;
	}

	.search_fd6_0_c0_c1_c0 {
		width: 32rpx;
		height: 10rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.search_fd6_0_c0_c1 {
		padding: 40rpx 0rpx 48rpx 0rpx;
	}

	.search_fd6_0_c0_c0 {
		width: 40rpx;
	}

	.search_fd6_0_c0 {
		padding: 0rpx 13rpx 0rpx 0rpx;
	}

	.search_fd6_0 {
		background: var(--benbenbgColor1);
		background-size: 100% auto !important;
		border-radius: 24rpx 24rpx 0rpx 0rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
	}
</style>